package com.benio.ycfdisplayer.fresco;

import android.content.Context;
import android.net.Uri;
import android.util.AttributeSet;

import com.benio.ycfdisplayer.displayer.DisplayListener;
import com.benio.ycfdisplayer.displayer.YcfDisplayer;
import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.facebook.drawee.view.SimpleDraweeView;

/**
 * An {@link SimpleDraweeView} which uses {@link YcfDisplayer}
 * Created by zhangzhibin on 2016/9/8.
 */
public class FrescoDraweeView extends SimpleDraweeView {

    public FrescoDraweeView(Context context, GenericDraweeHierarchy hierarchy) {
        super(context, hierarchy);
    }

    public FrescoDraweeView(Context context) {
        super(context);
    }

    public FrescoDraweeView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public FrescoDraweeView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public FrescoDraweeView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public void setImageURI(Uri uri, Object callerContext) {
        setImageURI(uri != null ? uri.toString() : "", null, null);
    }

    public void setImageURI(String uriString, FrescoDisplayOptions options) {
        setImageURI(uriString, options, null);
    }

    public void setImageURI(String uriString, FrescoDisplayOptions options, DisplayListener listener) {
        YcfDisplayer.get().display(uriString).listener(listener).options(options).into(this);
    }
}
